import { iDeviceStatistic } from '@/interface/iDeviceStatistic';
import { Paxios } from '../base';
import { iDeviceByGroup } from '@/interface/iDeviceByGroup';
import { iAnalysisStatistic } from '@/interface/iAnalysisStatistic';
import { iAnalysisSampingPoints } from '@/interface/iAnalysisSampingPoints';
import { iAnalysisHistory } from '@/interface/iAnalysisHistory';
/**
 * 查询样品
 * @returns
 */
export function apiGetSamples(): Promise<iRespBase<string[]>> {
    return Paxios.getInstance().get('/get_samples');
}
/**
 * 添加样品
 * @param name
 * @returns
 */
export function apiAddSample(name: string): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/add_sample', { name });
}
/**
 * 删除样品
 * @param name
 * @returns
 */
export function apiDelSample(name: string): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/del_sample', { name });
}
/**
 * 查询分析项目
 * @returns
 */
export function apiGetAnslysisProjects(): Promise<iRespBase<{ name: string; elements: string[] }[]>> {
    return Paxios.getInstance().get('/get_analysis_projects');
}
/**
 * 添加分析项目
 * @param data
 * @returns
 */
export function apiPostAddAnslysisProjects(data: { name: string; elements: string[] }): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/add_analysis_project', { data });
}
/**
 * 删除分析项目
 * @param data
 * @returns
 */
export function apiDelAnslysisProjects(data: { name: string }): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/del_analysis_project', { data });
}
/**
 * 查询取样点
 * @returns
 */
export function apiGetSamplingPoints(): Promise<iRespBase<iSamplingPoints[]>> {
    return Paxios.getInstance().get('/get_sampling_points');
}
/**
 * 添加取样点
 * @param data
 * @returns
 */
export function apiAddSamplingPoints(data: iSamplingPoints): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/add_sampling_project', { data });
}
/**
 * 删除取样点
 * @param data
 * @returns
 */
export function apiDelSamplingPoints(data: { name: string }): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/del_sampling_project', { data });
}
/**
 * 获取组别
 * @returns
 */
export function apiGetGroups(system_project: string): Promise<iRespBase<{ parent_name: string; second_name: string; url: string }[]>> {
    return Paxios.getInstance().get('/get_groups', { system_project });
}
/**
 * 添加组别
 * @param data
 * @returns
 */
export function apiAddGroups(data: { parent_name: string; second_name: string }): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/add_group', data);
}
/**
 * 删除组别
 * @param data
 * @returns
 */
export function apiDelGroups(data: { parent_name: string; second_name: string }): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/del_group', data);
}
//--------------------设备管理--------------------------------------
/**
 * 获取所有设备
 * @returns
 */
export function apiGetDevices(): Promise<iRespBase<iDevice[]>> {
    return Paxios.getInstance().get('/get_devices');
}
/**
 * 查询指定组别设备
 * @param group_parent_name
 * @returns
 */
export function apiGetDeviceByGroup(group_parent_name: string, group_second_name: string): Promise<iRespBase<iDeviceByGroup[]>> {
    return Paxios.getInstance().get('/get_device_by_group', { group_parent_name, group_second_name });
}
/**
 * 添加设备
 * @param data
 * @returns
 */
export function apiAddDevice(data: iDevice): Promise<iRespBase<void>> {
    return Paxios.getInstance().post('/add_device', data);
}
/**
 *  获取统计设备
 * @returns
 */
export function apiGetDeviceStatistic(): Promise<iRespBase<iDeviceStatistic>> {
    return Paxios.getInstance().get('/get_device_statistic');
}
/**
 * 获取设备运行
 * @param params
 * @returns
 */
export function apiGetDeviceData(params: {
    group_parent_name: string;
    group_second_name: string;
    type: string;
    analysis_project: string;
}): Promise<iRespBase<{ name: string; value: string }[]>> {
    return Paxios.getInstance().get('/get_device_data', params);
}
/**
 * 查询指定设备详细信息
 * @param params
 * @returns
 */
export function apiGetDeviceInfo(params: { group_parent_name: string; group_second_name: string; device_name: string }): Promise<iRespBase<any>> {
    return Paxios.getInstance().get('get_device_info', params);
}
/**
 * 统计分析概览
 * @returns
 */
export function apiGetAnalysisStatistic(days: number): Promise<iRespBase<iAnalysisStatistic>> {
    return Paxios.getInstance().get('/get_analysis_statistic', { days });
}
/**
 * 分析取样点信息
 * @returns
 */
export function apiGetAnalysisSampingPoints(days: number): Promise<iRespBase<iAnalysisSampingPoints[]>> {
    return Paxios.getInstance().get('/get_analysis_sampling_points', { days });
}
/**
 * 分析实时数据
 * @param parmas
 * @returns
 */
export function apiGetAnalysisRealtime(): Promise<iRespBase<iAnalysisHistory[]>> {
    return Paxios.getInstance().get('/get_analysis_realtime');
}
/**
 *
 * @param parmas 取样点历史记录
 * @returns
 */
export function apiGetHistoryByTag(parmas: {
    start: Date;
    end: Date;
    sampling_pt: string;
    analysis_project: string;
    status: string;
}): Promise<iRespBase<iAnalysisHistory[]>> {
    return Paxios.getInstance().get('/get_analysis_history', parmas);
}
/**
 * 报警概况
 * @returns
 */
export function apiGetWarningStatistic(days: number): Promise<iRespBase<{ time: string; abnormal_count: number; normal_count: number }[]>> {
    return Paxios.getInstance().get('/get_warning_statistic', { days });
}
/**
 * 获取分析数据报警情况
 * @returns
 */
export function apiGetAlarmHistory(params: { start: Date; end: Date; type: 0 | 1 }): Promise<iRespBase<any>> {
    return Paxios.getInstance().get('/get_alarm_history', params);
}
/**
 * 获取主项目
 * @returns
 */
export function apiGetSystemProject(): Promise<iRespBase<string[]>> {
    return Paxios.getInstance().get('/get_system_project');
}
